package com.license.common.util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;

public class Utils {
	
	public  double twoDecimalPlaces( double d) {
	    return new java.math.BigDecimal(d).setScale(2, 
	        java.math.RoundingMode.HALF_UP).doubleValue();
	}
	
	public List<Integer> getIntegerList(int listSize, int maxValue){
		List <Integer> maxList = new ArrayList<Integer>(maxValue);
		List<Integer> newList = new ArrayList<Integer>(listSize);
		for(int i = 0; i < maxValue; i++)
		{
			maxList.add(i);
		}
		Collections.shuffle(maxList);
		newList = maxList.subList(0, listSize);
		return newList;
	}
	
	public List<Double> getListFromInterval(double a, double b){
		List<Double> doubles = new ArrayList<>();
		doubles.add(a);
		doubles.add(this.twoDecimalPlaces((2*a+b)/3));
		doubles.add(this.twoDecimalPlaces((a+2*b)/3));
		doubles.add(b);
		return doubles;
	}
	
	public List<Boolean> getBooleanList(){
		return Arrays.asList(new Boolean[] {true, false});
	}
	

	public List<String> getGenderList(){
		return Arrays.asList(new String[]{"f", "m"});
	}
	
	public double generateRandomDouble(double a, double b) {
		Random rand = new Random();
		return rand.nextDouble()*(b-a) + a;
	}
	
	public int generateRandomInt(int a, int b) {
		Random rand = new Random();
		return rand.nextInt(b-a) + a;
	}
}